package cn.uniqueinfo.dp.controller;

import cn.uniqueinfo.dp.controller.base.BaseController;
import cn.uniqueinfo.dp.service.IPermissionService;
import cn.uniqueinfo.dp.util.ResultUtil;
import cn.uniqueinfo.dp.vo.PermissionVO;
import cn.uniqueinfo.dp.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author:朱元勋
 * @mail:395910063@qq.com
 * @date:2019-01-23 14:48:18
 * @description:业务单据权限点
 */
@Slf4j
@Controller
@RequestMapping(value = "/permission")
public class PermissionController extends BaseController<PermissionVO> {
    private IPermissionService service;

    public PermissionController(IPermissionService service) {
        this.service = service;
        this.baseService = service;
        this.ctlName = "permission";
        this.tipName = "业务单据权限点";
    }

    /** 系统业务权限点 */
    @GetMapping(value = {"/sys"})
    public ModelAndView system() {
        this.checkPermission("index", "index");
        return new ModelAndView("/" + ctlName + "/system");
    }

    @GetMapping("/find")
    @ResponseBody
    public List<PermissionVO> findByFormName(@RequestParam(value = "fn") String formName) {
        return this.service.findByFormName(formName);
    }

    @GetMapping("/fr")
    @ResponseBody
    public List<PermissionVO> findByRole(
            @RequestParam(value = "rid") Long rid, @RequestParam(value = "fn") String formName) {
        return this.service.findeByRole(rid, formName);
    }


}
